//
//  HXTConsumViewModel.m
//  HonlivApp
//
//  Created by admin on 2017/6/27.
//  Copyright © 2017年 honliv. All rights reserved.
//

#import "HXTConsumViewModel.h"
#import "CardConsumModel.h"

static NSString *const consum_url = @"api/Hxt/HxtInfoxiaofeimx?HxtCardNo=";

@implementation HXTConsumViewModel

-(void)getHXTConsumWithPage:(NSString *)page success:(void (^)())completion{
    User *user = [User currentUser];
    NSString *url = [NSString stringWithFormat:@"%@%@%@&pageNumber=%@&pageSize=10",HOSPITAL_URL,consum_url,user.MedicalCard,page];
    [NetWorker getHXTDatasWithURLStr:url success:^(id result) {
        NSArray *resultArr = [JsonHelper arrayWithJsonString:result[@"result"][@"dataList"]];
        NSMutableArray *modelArr = [NSMutableArray array];
        for (NSString *jsonStr in resultArr) {
            CardConsumModel *model = [CardConsumModel yy_modelWithJSON:jsonStr];
            [modelArr addObject:model];
        }
        _datasArray = modelArr;
        completion();
        
    } failure:^(id result) {
        _datasArray = [NSArray array];
        completion();
    }];

}

@end
